package com.skit.ecm.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.skit.ecm.databinding.FragmentHomeBinding
import com.skit.main.fragment.HomeActivityFragment
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class HomeFragment : Fragment() {
    private lateinit var binding: FragmentHomeBinding

    public lateinit var scrollGJ: (Int) -> Unit

    companion object {
        fun newInstance(): HomeFragment {
            val args = Bundle()

            val fragment = HomeFragment()
            fragment.arguments = args
            return fragment
        }

    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
//        val view = inflater.inflate(R.layout.fragment_home, container, false)
        binding = FragmentHomeBinding.inflate(inflater, container, false)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        binding.tabLayout.setViewPager(
            binding.viewPager, arrayOf("头条", "热榜", "闲聊", "推荐", "活动", "话题", "问答"), activity,
            arrayListOf(
                HomeActivityFragment.newInstance().apply {
                    scrollGJ = this@HomeFragment.scrollGJ
                },
                HomeActivityFragment.newInstance().apply {
                    scrollGJ = this@HomeFragment.scrollGJ
                },
                HomeActivityFragment.newInstance().apply {
                    scrollGJ = this@HomeFragment.scrollGJ
                },
                HomeActivityFragment.newInstance().apply {
                    scrollGJ = this@HomeFragment.scrollGJ
                },
                HomeActivityFragment.newInstance().apply {
                    scrollGJ = this@HomeFragment.scrollGJ
                },
                HomeActivityFragment.newInstance().apply {
                    scrollGJ = this@HomeFragment.scrollGJ
                },
                HomeActivityFragment.newInstance().apply {
                    scrollGJ = this@HomeFragment.scrollGJ
                }
            )
        )
    }


}